package com.gainloop.Listeners;

import java.util.ArrayList;

import org.alexd.jsonrpc.JSONRPCException;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.gainloop.Adapters.HelpAdapter;
import com.gainloop.Api.Helps;
import com.gainloop.Api.Entity.Help;

public class HelpIgnoreButtonListener implements View.OnClickListener{
	ArrayList<Help> _currentHelps;
	Help _currentHelp;
	HelpAdapter _helpAdapter;
	Context _context;
	
	public HelpIgnoreButtonListener(Context context ,ArrayList<Help> currentHelps,  HelpAdapter helpAdapter,Help currentHelp){
		Log.v("Tag Resolved Button Listener","created");
		_currentHelps=currentHelps;
		_helpAdapter = helpAdapter;
		_currentHelp=currentHelp;
		_context=context;
	}
	
	@Override
	public void onClick(View view) {
		Log.v("Help Ignore Button Listener","clicked!");
		_currentHelps.remove(_currentHelp);
		try {
			Helps.getInstance().setHelpIgnored(_currentHelp);
		} catch (JSONRPCException e) {
			e.printStackTrace();
			throw new RuntimeException("Error ignoring help");
		}
		//view.setVisibility(View.INVISIBLE);
		Toast.makeText(_context, "The help is ignored!", Toast.LENGTH_LONG).show();

		_helpAdapter.notifyDataSetChanged();
	}
}
